<?php
namespace app\admin\validate;

use think\Validate;

class MenuValidate extends Validate
{
    protected $rule =   [
        'id'          => 'require|number',
        'page'        => 'require|number',
        'limit'       => 'require|number',
        'name'        => 'require|length:1,30',
        'rule'        => 'length:1,200',
        'icon'        => 'length:5',
        'sort'        => 'require',
    ];
    
    protected $message  =   [
        'id.require'          => 'ID必须',
        'id.number'           => 'ID必须是数字',
        'page.require'        => '页数不能为空',
        'page.number'         => '页数数据类型错误',
        'limit.require'       => '条数不能为空',
        'limit.number'        => '条数数据类型错误',
        'name.require'        => '名称不能为空',
        'name.length'         => '名称长度错误',
        'rule.length'         => '路径长度错误',
        'icon.length'         => '图标长度错误',
        'sort.length'         => '排序值不能为空',
    ];
    
    protected $scene = [
        'show'         => ['id'],
        'editSort'     => ['id', 'sort'],
        'edit'         => ['id', 'name', 'rule', 'sort', 'icon'],
        'add'          => ['name', 'rule', 'sort', 'icon'],
    ];
}